package com.ljw.spring.annotation.ext;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @FileName MyApplicationListener
 * @Description TODO 应用监听器（监听ApplicationEvent及其子类事件）
 * @Author ljw
 * @Date 2021/2/4 2:54
 * @Version 1.0
 */
@Component
public class MyApplicationListener implements ApplicationListener<ApplicationEvent> {

    //IOC容器发布ApplicationEvent及其子类事件，则调用下面方法。类似于观察者模式
    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        System.out.println("接收事件："+event);
    }
}
